package com.ly.web.controller.erp;

import com.ly.common.annotation.Log;
import com.ly.common.core.controller.BaseController;
import com.ly.common.core.domain.AjaxResult;
import com.ly.common.core.page.TableDataInfo;
import com.ly.common.enums.BusinessType;
import com.ly.common.utils.poi.ExcelUtil;
import com.ly.heart.domain.KingBaseTaxRateCategoryEntity;
import com.ly.heart.service.IKingBaseTaxRateCategoryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 金蝶-税率-税种 前端控制器
 * </p>
 *
 * @author WuZH
 * @since 2024-08-20
 */
@Api ( value = "KingBaseTaxRateCategory", tags = "金蝶-税率-税种" )
@RestController
@RequestMapping ( "/heart/KingBaseTaxRateCategory" )
public class KingBaseTaxRateCategoryController extends BaseController {

    @Resource
    private IKingBaseTaxRateCategoryService kingBaseTaxRateCategoryService;

    /**
     * 查询金蝶-税率-税种列表
     */
    @PreAuthorize("@ss.hasPermi('heart:KingBaseTaxRateCategory:list')")
    @PostMapping("/list")
    @ApiOperation("查询金蝶-税率-税种列表")
    public AjaxResult getKingBaseTaxRateCategoryList(@RequestBody KingBaseTaxRateCategoryEntity kingBaseTaxRateCategoryEntity){
        return kingBaseTaxRateCategoryService.getKingBaseTaxRateCategoryList(kingBaseTaxRateCategoryEntity);
    }

    /**
     * 导出金蝶-税率-税种列表
     */
    @PreAuthorize("@ss.hasPermi('heart:KingBaseTaxRateCategory:export')")
    @Log(title = "金蝶-税率-税种", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    @ApiOperation("导出金蝶-税率-税种列表")
    public AjaxResult export(KingBaseTaxRateCategoryEntity kingBaseTaxRateCategoryEntity)
    {
        List<KingBaseTaxRateCategoryEntity> list = kingBaseTaxRateCategoryService.selectKingBaseTaxRateCategoryEntityList(kingBaseTaxRateCategoryEntity);
        ExcelUtil<KingBaseTaxRateCategoryEntity> util = new ExcelUtil<KingBaseTaxRateCategoryEntity>(KingBaseTaxRateCategoryEntity.class);
        return util.exportExcel(list, "info");
    }

    /**
     * 获取金蝶-税率-税种详细信息
     */
    @PreAuthorize("@ss.hasPermi('heart:KingBaseTaxRateCategory:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation("获取金蝶-税率-税种详细信息")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(kingBaseTaxRateCategoryService.selectKingBaseTaxRateCategoryEntityById(id));
    }

    /**
     * 新增金蝶-税率-税种
     */
    @PreAuthorize("@ss.hasPermi('heart:KingBaseTaxRateCategory:add')")
    @Log(title = "金蝶-税率-税种", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation("新增金蝶-税率-税种")
    public AjaxResult add(@RequestBody KingBaseTaxRateCategoryEntity kingBaseTaxRateCategoryEntity)
    {
        return toAjax(kingBaseTaxRateCategoryService.insertKingBaseTaxRateCategoryEntity(kingBaseTaxRateCategoryEntity));
    }

    /**
     * 修改金蝶-税率-税种
     */
    @PreAuthorize("@ss.hasPermi('heart:KingBaseTaxRateCategory:edit')")
    @Log(title = "金蝶-税率-税种", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation("修改金蝶-税率-税种")
    public AjaxResult edit(@RequestBody KingBaseTaxRateCategoryEntity kingBaseTaxRateCategoryEntity)
    {
        return toAjax(kingBaseTaxRateCategoryService.updateKingBaseTaxRateCategoryEntity(kingBaseTaxRateCategoryEntity));
    }

    /**
     * 删除金蝶-税率-税种
     */
    @PreAuthorize("@ss.hasPermi('heart:KingBaseTaxRateCategory:remove')")
    @Log(title = "金蝶-税率-税种", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    @ApiOperation("删除金蝶-税率-税种")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(kingBaseTaxRateCategoryService.deleteKingBaseTaxRateCategoryEntityByIds(ids));
    }

    @Log (title = "禁用金蝶-税率-税种", businessType = BusinessType.DELETE)
    @RequestMapping ("disabled")
    @ApiOperation ("禁用金蝶-税率-税种")
    public AjaxResult disabled (String id) {
        return kingBaseTaxRateCategoryService.disabled ( id );
    }

}
